Skip to content

ExpressiveCommand reads a procedure's parameter names asynchronously - #302

Merged
electricessence merged 6 commits into
masterfrom
fix/command-async-names
Dec 2, 2026
Merged

electricessence merged 6 commits into
masterfrom
fix/command-async-names

Conversation

@electricessence

@electricessence electricessence commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

An ExpressiveCommand (a command made over an IDbConnection) that runs a stored procedure asynchronously read the procedure's parameter names with a blocking GetSchema call on the calling thread. ExpressiveDbCommand already overrides the asynchronous method and uses GetSchemaAsync; ExpressiveCommand overrode only the synchronous one, so the base class's default wrapped the blocking call.

The change

ExpressiveCommand overrides GetProcedureParameterNamesAsync the way ExpressiveDbCommand does: when the connection is a DbConnection it calls ProcedureSchemaNames.GetAsync; any other connection has no names. The lookup is asynchronous on net10.0 and later (GetSchemaAsync, with the caller's token). The netstandard targets have no such method: there the lookup is still synchronous, as before, and the token is only checked before it starts. The documentation says so per target. The override is added to the unshipped public API list. No release note: the behavior only differs in not blocking the thread on net10.0 and later.

Cost

Once per procedure and connection, when the names are first read: the same single schema read as before, now asynchronous on net10.0 and later. A call whose names are already known pays nothing.

Tests

Four in ProcedureSchemaNamesTests, over a fake DbConnection behind an IDbConnection: the asynchronous run reads the names with GetSchemaAsync (with the override reverted this test failed with Expected: 1, Actual: 0 on the asynchronous call count), the synchronous run still uses GetSchema, the asynchronous lookup over a connection that is not a DbConnection gives no names, and the caller's token reaches GetSchemaAsync.

Reviews

A three-lens review (correctness and tests, the repository's written rules, documentation accuracy) found no defect in the change. Applied: the netstandard wording, the OperationCanceledException documentation, a test comment. Not applied: the asynchronous-path test asserts the asynchronous call count only (a stronger assertion would need a fake that does not call the base), and the non-DbConnection test passes without the override because the base default gives the same answer; both are noted as limits, the first test fails without the override.

Checks: Release and Debug tests pass, 0 build warnings, 267 sample checks, VS MSBuild 0 errors, dotnet format style and analyzers clean on all 28 checks, DocFX 0 warnings, the style scan clean.

🤖 Generated with Claude Code

electricessence and others added 6 commits December 2, 2026 13:03
…onously

An asynchronous run of a stored procedure on a command made over an
IDbConnection that is a DbConnection looked the parameter names up with the
blocking GetSchema call, on the async thread and without observing the
cancellation token. ExpressiveCommand now overrides the asynchronous
GetProcedureParameterNamesAsync as ExpressiveDbCommand does, so the lookup
uses GetSchemaAsync on net10.0 and net11.0 (the netstandard targets keep
the synchronous lookup, as before).

Cost: first use of a procedure per connection only, nothing per call or row.
Not user-visible beyond not blocking, so no release-notes line.

Tests: an ExpressiveCommand over a DbConnection held as IDbConnection
records GetSchemaAsync on the async path and GetSchema on the sync path.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ames

# Conflicts:
#	Source/Core/PublicAPI.Unshipped.txt
…more

The override's summary now says the lookup is asynchronous on net10.0 and
later (GetSchemaAsync) and synchronous on the netstandard targets. Its
header and inheritdoc are wrapped to about 80 columns.

Tests: the synchronous run is written one call per line; an asynchronous
lookup over a connection that is not a DbConnection gives no names and
touches nothing; the caller's cancellation token reaches GetSchemaAsync.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…inly

The cancellation token of the asynchronous names lookup can cancel it only on
net10.0 and later; on the netstandard targets it is checked before the
synchronous lookup starts, and the call blocks the thread and returns a
completed task. Say so in the override's documentation, and document the
OperationCanceledException. A test comment no longer claims what the default
GetSchemaAsync does.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@electricessence
electricessence merged commit 1b36202 into master Dec 2, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant